type SelectProps = {
  label?: string;
  options: string[];
  onChange?: (value: string) => void;
};

export default function Select(props: SelectProps) {
  const { label, options, onChange } = props;
  return (
    <label className="flex items-baseline md:block">
      <span className="flex-none basis-12">{label}</span>
      <select
        onChange={(e) => onChange(e.target.value)}
        className="min-w-0 flex-auto rounded bg-zinc-200 px-2 py-1 md:w-max"
      >
        {options.length === 0 && (
          <option disabled value="no-content">
            没有数据
          </option>
        )}
        {options.map((option) => (
          <option key={option} value={option}>
            {option}
          </option>
        ))}
      </select>
    </label>
  );
}
